package xmist.edu.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class ThreadDemo03 implements Callable {
    public static void main(String[] args) {
        ThreadDemo03 threadDemo03 = new ThreadDemo03();
        FutureTask<String> task = new FutureTask<>(threadDemo03);
        new Thread(task).start();
        try {
            System.out.println("线程返回的数据："+task.get());
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }
    @Override
    public Object call() throws Exception {
        System.out.println("时限Callable接口，线程启动");
        return "success";
    }
}
